<template>
    <section class="modlude">
        <el-form :inline="true" :model="formSearch" class="form_inline" label-width="80px">
            <el-form-item label="设备名称" size="small">
                <el-input v-model="formSearch.doorName" placeholder="请选择设备名" clearable></el-input>
            </el-form-item>
            <el-form-item label="用户名称" size="small">
                <el-input v-model="formSearch.userName" placeholder="请输入操作用户" clearable></el-input>
            </el-form-item>
            <el-form-item label="开门类型" size="small">
                <el-select v-model="formSearch.typeDesc" clearable>
                    <el-option label="密码开锁" :value="0"></el-option>
                    <el-option label="扫码开锁" :value="1"></el-option>
                    <el-option label="人脸开锁" :value="2"></el-option>
                    <el-option label="一键开锁" :value="3"></el-option>
                    <el-option label="蓝牙开锁" :value="4"></el-option>
                    <el-option label="IC卡开锁" :value="5"></el-option>
                    <el-option label="ID卡开锁" :value="6"></el-option>
                    <el-option label="身份证开锁" :value="7"></el-option>
                    <el-option label="对讲开锁" :value="8"></el-option>
                    <el-option label="指纹开锁" :value="10"></el-option>
                    <el-option label="电脑开锁" :value="11"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="开门时间" size="small" class="range">
            <el-date-picker
                v-model="formSearch.timeRange"
                type="datetimerange"
                clearable
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="至"
                start-placeholder="开始"
                end-placeholder="结束"
            ></el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="进入时间" size="small">
                <el-date-picker v-model="formSearch.startTime" type="datetime" clearable value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="进入时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="离开时间" size="small">
                <el-date-picker v-model="formSearch.endTime" type="datetime" clearable value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="离开时间">
                </el-date-picker>
            </el-form-item> -->
            <el-form-item>
                <el-button size="small" @click="sendData">查 询</el-button>
            </el-form-item>
        </el-form>
    </section>
</template>

<script>
import {
    getInsertDoorLog,
} from '../../../url/api';
export default {
    data() {
        return {
            checkStrictly: false,
            moduleInfor: {},
            bindRole: {},
            showmenuList: [],
            menuList: [],
            option1: [],
            xqTree: [],
            isAddorUpdate: 1, //1添加、2修改
            formSearch: {
                current: 1,
                size: 10,
                startTime:"",
                endTime:"",
                timeRange: []
            },
            formData: [], //数据
            deleBatch: [], //删除数据
            formUpdate: {}, //修改表单
            total: 0, //数据总数
            pages: 0, //页面总数
            addDialog: false,
            updateDialog: false,
            dialog: false,
            replyType: 1, //1。单个回复 2.批量回复
            formPush: {},
            rules: {
                name: [{ required: true, message: '该项不能为空' }],
                type: [
                    {
                        required: true,
                        message: '该项不能为空',
                        trigger: 'blur',
                    },
                ],
                projectId: [
                    {
                        required: true,
                        message: '该项不能为空',
                        trigger: 'blur',
                    },
                ],
            },
            imageUrl: '',
        };
    },
    methods: {
        sendData(){
            if (this.formSearch.timeRange && this.formSearch.timeRange.length === 2) {
            this.formSearch.startTime = this.formSearch.timeRange[0]
            this.formSearch.endTime = this.formSearch.timeRange[1]
        }
        console.log('emit加载')
        this.formSearch.current = 1
        this.Bus.$emit('sendTableDatapk_acs',{
          formSearch:this.formSearch,
          // total:this.total
      })
      },
        // getList() {
        //     this.formSearch.current= 1;
        //     console.log(this.formSearch.current);
        //     let params = {
        //           current:this.formSearch.current,
        //           size:this.formSearch.size,
        //           startTime:this.formSearch.startTime,
        //           endTime:this.formSearch.endTime,
        //           typeDesc:this.formSearch.typeDesc,
        //           name:this.formSearch.name,
        //           userName:this.formSearch.userName
        //     }
        //     getInsertDoorLog(params).then((res) => {
        //                 if (res.data.ok) {
        //                     this.formData = res.data.data.records
        //                     this.total = res.data.data.total
        //                 }
        //             });
        // },
    },
    watch: {
    'formSearch.timeRange': function(newVal) {
    if (!newVal || newVal.length !== 2) {
      this.formSearch.startTime = ''
      this.formSearch.endTime = ''
    }
  }
  },
};
</script>
<style scoped lang='scss'>
.form_inline /deep/ .el-form-item {
    margin: 10px 0px;
}
.form_inline /deep/ .el-date-editor.el-input,
.el-date-editor.el-input__inner {
    width: 156px;
}
/* .cont_box {
    width: 100%;
    display: flex;
}
.cont_box_left,
.cont_box_right {
    flex: 1;
    background: transparent;
    padding: 10px;
}
.cont_box_left {
    margin-right: 10px;
}
.margin10 {
    margin-bottom: 10px;
}
.marginRight {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
}
.cont_box_right .el-form-item {
    margin-bottom: 20px;
} */
/deep/.range>.el-form-item__content{
    width: 350px;
}
/deep/.el-input__inner[data-v-371c86aa]  {
    width: 350px;
    max-width: 350px;
}
</style>
